local fengxi = fk.CreateSkill {
  name = "lingling__fengxi",
}

Fk:loadTranslationTable{
  ["lingling__fengxi"] = "烽戏",
  [":lingling__fengxi"] = "出牌阶段限一次，你可以视为使用【烽火狼烟】，若没有角色打出【杀】，你失去此技能，摸三张牌，随机获得一个技能。",

  ["#lingling__fengxi"] = "烽戏：你可以视为使用【烽火狼烟】！",
}

fengxi:addEffect("viewas", {
  anim_type = "offensive",
  mute_card = false,
  prompt = "#lingling__fengxi",
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if #cards ~= 0 then return end
    local card = Fk:cloneCard("ling__savage_assault")
    card.skillName = fengxi.name
    return card
  end,
  after_use = function (self, player, use)
    if not player.dead then
      local yes = use == nil
      if not yes then
        yes = #player.room.logic:getEventsByRule(GameEvent.RespondCard, 1, function(e)
          local response = e.data
          return response.card.trueName == "slash" and
            response.responseToEvent.card and
            table.contains(response.responseToEvent.card.skillNames, fengxi.name)
        end, nil, Player.HistoryPhase) == 0
      end
      if yes then
        local room = player.room
        room:handleAddLoseSkills(player, "-lingling__fengxi")
        player:drawCards(3, fengxi.name)
        if player.dead then return end
        local skills = {}
        for g, general in pairs(Fk.generals) do
          if not table.contains(Fk:currentRoom().disabled_generals, g) and general.package.extensionName == "lingling" then
            for _, s in ipairs(general:getSkillNameList()) do
              if not player:hasSkill(s, true) then
                table.insertIfNeed(skills, s)
              end
            end
          end
        end
        room:handleAddLoseSkills(player, table.random(skills))
      end
    end
  end,
  enabled_at_play = function (self, player)
    return player:usedSkillTimes(fengxi.name, Player.HistoryPhase) == 0
  end,
})

fengxi:addAI(nil, "vs_skill")

return fengxi
